package com.algorithms.datatypes;

import com.algorithms.absdatatypes.Heap;
import com.algorithms.absdatatypes.MinPriorityQueue;
import com.algorithms.absdatatypes.Node;

public class MinPriorityQueueImpl<K extends Comparable,T> implements MinPriorityQueue<K,T>
{
	Heap<K,T> heap;
	public MinPriorityQueueImpl(Heap<K,T> heapPriorityQueue)
	{
		heap=heapPriorityQueue;
	}
	public MinPriorityQueueImpl()
	{

		heap=new Heap<K,T>();
	}
	
	 
	public void insert(Node<K,T> element)
	{
		
		heap.insertData(element);
	}

	 
	public Node<K,T> minimum()
	{
		
		return heap.getMin();
	}

	 
	public Node<K,T> extractMin()
	{
		
		return heap.extractMin();
	}

	 
	public void decreaseKey(Node<K,T> from, Node<K,T> to)
	{
		int location =heap.findKeyinHeap(from);
		heap.decreaseKey(location,to);
	}
	 
	public boolean isEmpty()
	{
		System.out.println(heap.getDataArray().length);
		if(heap==null || heap.getDataArray()==null || heap.getDataArray().length <1)
			return true;
		return false;
	}
	 
	public Node<K, T> findKey(K node)
	{
		return heap.findNodeForKeyinHeap(node);
	}

}
